<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>	
<div class="table-responsive">
<table class="cntable table table-bordered dataTable table-shop">
	<thead>
		<tr>
			<th style="width:50px">序号</th>
			
			<th style="width:120px">商品编码</th>	
			<th style="width:120px">商品名称</th>
			<th style="width:120px">商品规格</th>
			<th style="width:120px">基本单位</th>
			<th style="width:120px">供应价</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="supplyCargo" items="${supplyCargos}" varStatus="status">
			
			<tr data-id="${supplyCargo.id}" style="height:60px">
				<td>${status.index+1}</td>
				
		
				<td>${supplyCargo.cargo.cargoNo}</td>
				<td style="white-space:normal">${supplyCargo.cargo.cargoName }</td>
				<c:if test="${supplyCargo.collocation.propertyNameOne ne null &&supplyCargo.collocation.propertyNameTwo ne null }">
					<td>${supplyCargo.collocation.propertyNameOne }*${supplyCargo.collocation.propertyNameTwo }</td>
				</c:if>
				<c:if test="${supplyCargo.collocation.propertyNameOne ne null &&supplyCargo.collocation.propertyNameTwo eq null }">
					<td>${supplyCargo.collocation.propertyNameOne }</td>
				</c:if>
				<c:if test="${supplyCargo.collocation.propertyNameOne eq null &&supplyCargo.collocation.propertyNameTwo eq null }">
					<td></td>
				</c:if>
				<td>${supplyCargo.cargo.unit}</td>
				<td>
					<input type="number" onchange="savePrice('${supplyCargo.id}',this)" class="form-control"  value="${supplyCargo.supplyPrice }" placeholder="${supplyCargo.supplyPrice }" >
				</td>
				
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
		<tr>
			<th class="pager-th">
				<%@ include file="/WEB-INF/views/shared/master/simplePager2.jsp"%>
			</th>
		</tr>
	</tfoot>
</table>

</div>
<script type="text/javascript">

$(function(){
	$('.pic').popover({
	     trigger : 'hover',//鼠标以上时触发弹出提示框
	     html:true,//开启html 为true的话，data-content里就能放html代码了
	     content:"<img src='<c:url value='/images/hu.jpg'/>' >"
	 });

})


var price=0;

function savePrice(selectedId,element){
	price=$(element).val();

	$.ajax({
        type: 'post',
        dataType: "json",
        url: $.getVirtualPath()+"/shop/supplyCargo/change",
        
        data: "id="+selectedId+"&supplyPrice="+price,
        async: false,
        success: function (result) {
        	if(result.resultType=="error"){
        		$.topNotify("保存出错","warning");
        		
        	}else if(result.resultType=="success"){
        		$.topNotify("保存成功","success");
    			
        	}
        }
    });
}

</script>